package com.wiseasy.smartpos.cashierdemo;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;
import android.text.TextUtils;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

import com.wisepos.smartpos.WisePosSdk;

public class DiagnosticInfoActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_diagnostic_info);
        Button mBack = findViewById(R.id.pos_navbar_left_btn);
        mBack.setVisibility(View.VISIBLE);
        mBack.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
            }
        });



        TextView mTitle = findViewById(R.id.pos_navbar_title);
        mTitle.setText("Diagnostic Information");
        new Thread(new Runnable() {
            @Override
            public void run() {
                String info = WisePosSdk.getInstance().getTransProcess().getTransDiagInfo();
                if (!TextUtils.isEmpty(info)){
                    setDiagnosticTransInfo(info);
                } else {
                    setDiagnosticTransInfo("The information of Diagnostic transaction is empty!");
                }
            }
        }).start();
    }

    private void setDiagnosticTransInfo(String diagnosticTransInfo){
        Log.i("DiagnosticTransactionActivity", "setDiagnosticTransInfo: "+ diagnosticTransInfo);
        runOnUiThread(new Runnable() {
            @Override
            public void run() {
                ((TextView)findViewById(R.id.diagnosticTransInfoTV)).setText(diagnosticTransInfo);
            }
        });
    }

}